package com.itheima.homework.Five;

import java.util.Arrays;
import java.util.Comparator;

public class Demo1 {
    public static void main(String[] args) {

        Student[] stu = new Student[4];
        Student student1 = new Student("张三",18,180.0);
        Student student2 = new Student("李四",25,175.0);
        Student student3 = new Student("王五",19,178.0);
        Student student4 = new Student("老六",34,189.2);

        stu[0] = student1;
        stu[1] = student2;
        stu[2] = student3;
        stu[3] = student4;

        Arrays.sort(stu, (o1, o2) -> CompareByData.compareByAge(o1, o2));

        for (int i = 0; i < 4; i++) {
            System.out.println(stu[i]);
        }

        Arrays.sort(stu, (o1, o2) -> new CompareByData().compareByHeight(o1,o2));
            for (int i = 0; i < 4; i++) {
                System.out.println(stu[i]);
            }
    }
}
